package claybird.dom;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.ManyToOne;

@Entity
public class Handicap extends BaseEntity {

	public enum Categorie {
		candidat,
    	amateur,
    	chasseur,
    	tireur,
    	pro,
    	invite;
    }
	
	private Short year=0;
	private float previousHandicap= 0;
	private float currentHandicap= 0;
	@ManyToOne
	private Person person;
	@Enumerated(EnumType.STRING)
    private Categorie categorie;
	private int finalRanking;
	
	
	public void setYear(Short year) {
		this.year = year;
	}

	public Handicap(Person person){
		this.person = person;
		Calendar myCalendar = GregorianCalendar.getInstance();
		this.year = (short)myCalendar.get(myCalendar.YEAR);
		this.categorie = Categorie.candidat;
		if(person.isGuest())this.categorie = Categorie.invite;
	}
	
	public Handicap(){
		
	}
	
    
    public Handicap(Person person, Handicap lastHandicap,Short year) {
		this.person = person;
		this.year= year;
		this.categorie = lastHandicap.getCategorie();
		this.previousHandicap = lastHandicap.currentHandicap;
		this.currentHandicap = lastHandicap.currentHandicap;
		
	}

	public Categorie getCategorie() {
		return categorie;
	}
	public void setCategorie(Categorie categorie) {
		this.categorie = categorie;
	}
    public short getYear() {
		return this.year;
	}
	public void setYear(short annee) {
		this.year = annee;
	}
	public Person getPerson() {
		return person;
	}
	public void setPerson(Person personne) {
		this.person = personne;
	}

	public float getCurrentHandicap() {
		return currentHandicap;
	}

	public void setCurrentHandicap(float currentHandicap) {
		this.currentHandicap = currentHandicap;
	}

	public float getPreviousHandicap() {
		return previousHandicap;
	}

	public void setPreviousHandicap(float previousHandicap) {
		this.previousHandicap = previousHandicap;
	}

	public int getFinalRanking() {
		return finalRanking;
	}

	public void setFinalRanking(int finalRanking) {
		this.finalRanking = finalRanking;
	}

	
}
